import $ from 'jquery';

//设置跨域保留cookies
$.ajaxSetup({
    crossDomain: true,
    xhrFields: {
        withCredentials: true
    }
});

export default function ({type,url,data,success,error}) {
    $.ajax({
        type:type,
        url:url,
        data:data,
        dataType:"json",
        success:function (res) {
            if (res.code===-1)
                window.location.href=res.redirect;
            else
                success(res);
        },
        error:error
    })
}